import { killZone } from '../killZone';
import { isEntityOnCircle } from './point_on_circle';
export const circle: GameEntity[] = world
    .querySelectorAll('*')
    .filter((e) => e.id.startsWith('圆圈'));

circle.forEach((e) => {
    const id: number = parseInt(e.id.substring(3, e.id.length));
    const dir: number = -0.5 + (id % 2);
    setInterval(() => {
        e.meshOrientation.copy(e.meshOrientation.rotateY(dir / 10));
        killZone(e.position, 5, (a: GameEntity) => {
            if (a.player) {
                if (
                    isEntityOnCircle(
                        e.position,
                        3.5,
                        e.meshOrientation,
                        a.position,
                        1
                    )
                )
                    // world.createEntity({
                    //     mesh: 'mesh/点.vb',
                    //     position: a.position,
                    //     meshScale: new GameVector3(0.1, 0.1, 0.1),
                    //     gravity: false,
                    //     fixed: true,
                    //     collides: false
                    // })
                    {a.position.copy(a.player.spawnPoint);}
            }
        });
    }, 100);
});
